<template>
    <div class="login">
        <img
            src="https://xzcs-video.oss-cn-beijing.aliyuncs.com/pc/xiaozhu-screen/5da887cedd940.jpg"
            alt=""
            class="login-bj"
        />
        <div class="main">
            <div class="login-div">
                <img
                    src="https://xzcs-video.oss-cn-beijing.aliyuncs.com/pc/xiaozhu-screen/kuang.png"
                    class="bj-img"
                    alt=""
                />
                <div class="title">优亲贝贝数据管理平台</div>
                <div class="login-t">用户登陆</div>
                <div class="input-div">
                    <i class="el-icon-user-solid"></i>
                    <el-input
                        class="input"
                        v-model="username"
                        placeholder="账号"
                    ></el-input>
                </div>
                <div class="input-div" style="padding-top: 20px">
                    <i class="el-icon-s-order"></i>
                    <el-input
                        class="input"
                        v-model="password"
                        show-password
                        placeholder="密码"
                    ></el-input>
                </div>
                <div class="but" @click="screen_login">登陆</div>
            </div>
        </div>
    </div>
</template>

<script>
import { screen_login } from "@/api/homeIndex/homeIndex";
export default {
    name: "login",
    components: {},
    data() {
        return {
            username: "",
            password: "",
        };
    },
    created() {},
    mounted() {
    },
    methods: {
        screen_login() {
            if (!this.username) {
                this.$message({
                    message: "请输入账号",
                    type: "warning",
                });
                return;
            }
            if (!this.password) {
                this.$message({
                    message: "请输入密码",
                    type: "warning",
                });
                return;
            }
            screen_login({
                username: this.username,
                password: this.password,
            }).then((res) => {
                localStorage.setItem('token', res.data.data.userinfo.token)
                this.$router.push({
                    path: '/homeIndex'
                })
            });
        },
    },
};
</script>

<style lang="scss" scoped>
.login-bj {
    width: 100vw;
    height: 100vh;
    display: block;
    object-fit: cover;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
    user-select: none;
}

.main {
    position: fixed;
    z-index: 1;
    left: 52%;
    top: 36%;
}

.login-div {
    width: 460.8px;
    height: 328px;
    position: relative;
    .bj-img {
        width: 100%;
        height: 100%;
        display: block;
        position: absolute;
        top: 0;
        left: 0;
    }

    .title {
        color: transparent; /* 文本颜色设为透明 */
        background-image: linear-gradient(
            to bottom,
            #6ee8fb,
            #1083fc
        ); /* 渐变背景 */
        -webkit-background-clip: text; /*Webkit浏览器*/
        background-clip: text; /* 其他浏览器 */
        font-size: 37px;
        font-weight: 600;
        position: absolute;
        top: -80px;
        left: 0;
        width: 100%;
        text-align: center;
        user-select: none;
    }

    .login-t {
        color: #ffffff;
        font-size: 28px;
        text-align: center;
        width: 100%;
        padding-top: 40px;
        position: relative;
        z-index: 2;
        padding-bottom: 25px;
    }

    .input-div {
        text-align: center;
        position: relative;
        left: -10px;
        position: relative;
        z-index: 10;
        .input {
            width: 320px;
            &::v-deep .el-input__inner {
                border-radius: 0;
                padding-left: 40px;
            }
        }
        i {
            color: #1083fc;
            font-size: 28px;
            position: relative;
            left: 34px;
            z-index: 10;
            top: 5px;
        }
    }

    .but {
        background-image: linear-gradient(
            to bottom,
            #42c5fe,
            #0a69e3
        ); /* 渐变背景 */
        width: 250px;
        height: 40px;
        line-height: 40px;
        margin: 0 auto;
        text-align: center;
        font-size: 16px;
        color: #ffffff;
        margin-top: 35px;
        user-select: none;
        position: relative;
        z-index: 10;
        cursor: pointer;
        &:hover {
            opacity: 0.9;
        }
        &:active {
            opacity: 0.8;
        }
    }
}
</style>